package meconsea.life.cms.web;

import java.util.Map;

import meconsea.life.admin.accessor.AdminUserLogAccessor;
import meconsea.life.admin.accessor.IndicateAccessor;
import meconsea.life.admin.entity.AdminUser;
import meconsea.life.admin.entity.AdminUserLog;
import meconsea.life.admin.entity.Indicate;
import meconsea.life.cms.accessor.SArticleAccessor;
import meconsea.life.cms.accessor.XArticleAccessor;
import meconsea.life.cms.accessor.YArticleAccessor;
import meconsea.life.cms.accessor.ZArticleAccessor;
import meconsea.life.cms.entity.Article;
import meconsea.life.util.Constant;

import org.apache.log4j.Logger;

import com.google.inject.Inject;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ArticleAct extends ActionSupport {
	public static final Logger log = Logger.getLogger(ArticleAct.class);

	private String clsCode;
	private String clsName;
	private String artType;
	private String call;
	private Article article;
	
	private String id;
	
	private String title;

	private String subtitle;

	private String content;

	private String keywords;

	private String summary;

	private String specialId;

	private String artClass;

	private String artClassName;

	private String artClassPath;

	private String indexImg;

	private String homeImg;

	private String artResource;

	private String author;

	private Integer commend;

	private Integer top;

	private Integer hot;

	private Integer comment;

	private Integer clicks;

	private Integer statusFlg;

	private Integer auditLevel;

	private String htmlPath;

	private Integer isHeader;
	public String getClsName() {
		return clsName;
	}

	public void setClsName(String clsName) {
		this.clsName = clsName;
	}

	public String getClsCode() {
		return clsCode;
	}

	public void setClsCode(String clsCode) {
		this.clsCode = clsCode;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSubtitle() {
		return subtitle;
	}

	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getSpecialId() {
		return specialId;
	}

	public void setSpecialId(String specialId) {
		this.specialId = specialId;
	}

	public String getArtClass() {
		return artClass;
	}

	public void setArtClass(String artClass) {
		this.artClass = artClass;
	}

	public String getArtClassName() {
		return artClassName;
	}

	public void setArtClassName(String artClassName) {
		this.artClassName = artClassName;
	}

	public String getArtClassPath() {
		return artClassPath;
	}

	public void setArtClassPath(String artClassPath) {
		this.artClassPath = artClassPath;
	}

	public String getIndexImg() {
		return indexImg;
	}

	public void setIndexImg(String indexImg) {
		this.indexImg = indexImg;
	}

	public String getHomeImg() {
		return homeImg;
	}

	public void setHomeImg(String homeImg) {
		this.homeImg = homeImg;
	}

	public String getArtResource() {
		return artResource;
	}

	public void setArtResource(String artResource) {
		this.artResource = artResource;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public Integer getCommend() {
		return commend;
	}

	public void setCommend(Integer commend) {
		this.commend = commend;
	}

	public Integer getTop() {
		return top;
	}

	public void setTop(Integer top) {
		this.top = top;
	}

	public Integer getHot() {
		return hot;
	}

	public void setHot(Integer hot) {
		this.hot = hot;
	}

	public Integer getComment() {
		return comment;
	}

	public void setComment(Integer comment) {
		this.comment = comment;
	}

	public Integer getClicks() {
		return clicks;
	}

	public void setClicks(Integer clicks) {
		this.clicks = clicks;
	}

	public Integer getStatusFlg() {
		return statusFlg;
	}

	public void setStatusFlg(Integer statusFlg) {
		this.statusFlg = statusFlg;
	}

	public Integer getAuditLevel() {
		return auditLevel;
	}

	public void setAuditLevel(Integer auditLevel) {
		this.auditLevel = auditLevel;
	}

	public String getHtmlPath() {
		return htmlPath;
	}

	public void setHtmlPath(String htmlPath) {
		this.htmlPath = htmlPath;
	}

	public Integer getIsHeader() {
		return isHeader;
	}

	public void setIsHeader(Integer isHeader) {
		this.isHeader = isHeader;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public String getArtType() {
		return artType;
	}

	public void setArtType(String artType) {
		this.artType = artType;
	}

	public String getCall() {
		return call;
	}

	public void setCall(String call) {
		this.call = call;
	}

	@Inject
	private SArticleAccessor sArticleAccessor;
	@Inject
	private XArticleAccessor xArticleAccessor;
	@Inject
	private ZArticleAccessor zArticleAccessor;
	@Inject
	private YArticleAccessor yArticleAccessor;
	
	@Inject
	private IndicateAccessor indicateAcessor;

	@Inject
	private AdminUserLogAccessor adminUserLogAccessor;

	public String execute(){
		Map session = ActionContext.getContext().getSession();
		AdminUser au = (AdminUser)session.get(meconsea.life.util.Constant.ADMIN_USER_SESSION);
		if(au == null){
			return Constant.ADMIN_LOGIN;
		}
		AdminUserLog aul = new AdminUserLog();
		aul.setUserid(au.getId());
		aul.setLoginfo("访问内容管理"+clsCode+";Action="+getCall());
		adminUserLogAccessor.save(aul);
		Indicate indicate = indicateAcessor.getIndicateByClsCode(getClsCode());
		setClsName(indicate.getClsName());
		if("addUI".equals(getCall())){
			setArtClass(clsCode);
			setArtClassName(indicate.getClsName());
			setArtClassPath(indicate.getClsPath());
			log.debug("addUI.....");
			return this.SUCCESS;
		}else if("save".equals(getCall())){
			
			if(getId() != null && getId().length() > 1){//更新
				
			}else{//保存
				
			}
			
		}else if("editUI".equals(getCall())){
			
		}else if("del".equals(getCall())){
			
		}else if("top".equals(getCall())){
			
		}else if("commend".equals(getCall())){
			
		}else if("hot".equals(getCall())){
			
		}
		return null;
	}
}
